/**
 * 文件上传
 */

var upload_html = "<div id='__DIV_UPLOAD_MASK' style='display:block;position:absolute;z-index:8999;background-color:#000;filter:alpha(opacity=20);opacity:0.2;'></div><div id='__DIV_UPLOAD' style='position:absolute;border:none;z-index:9000;'></div>";
var $m;
var $u;
var $swf;

$( "body" ).ready( function( e )
{
	up_init();
} );

function up_init()
{
	$( "body" ).append( upload_html );
	$u = $( "#__DIV_UPLOAD" );
	$m = $( "#__DIV_UPLOAD_MASK" );
	$swf = $.browser.msie ? $( "#__SWF" ) : $( "#__SWF_EMBED" );

	$swf.width( 510 );
	$swf.height( 410 );
	$swf.appendTo( $u );
	$( "#flashContent" ).remove();

	$u.hide();
	$m.hide();
}

//窗口大小改变
$( window ).resize( function( e )
{
	if( $u.visible() )
	{
		up_open();
	}
} );

function up_open()
{
	var bw = $( "body" ).width();
	var bh = $( "body" ).height();
	var w = $swf.width();
	var h = $swf.height();

	$m.width( bw );
	$m.height( bh );
	$m.move( 0, 0 );
	$u.move( ( bw - w ) / 2, ( bh - h ) / 2 * 0.8 );

	//	$m.show();
	//	$u.show();
	$u.show();
	$m.fadeIn( 150 );
}

function up_close()
{
	//	$u.hide();
	//	$m.hide();
	$u.slideUp( 150 );
	$m.fadeOut( 150 );
}

//--------------------------------------------------------------------------
//
//	以下为 SWF中需要调用的JS方法
//
//--------------------------------------------------------------------------

function upload_close()
{
	up_close();
}

var _complete_fn = null;

function set_complete_fn( fn )
{
	_complete_fn = fn;
}

function upload_complete( value )
{
	if( _complete_fn != null )
	{
		_complete_fn( value );
	}
}
